package com.lhy.vip.controller;

import com.lhy.vip.service.ApplyMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lhy.vip.domain.ApplyMoney;
import com.itbuka.entity.Result;
import com.itbuka.entity.PageResult;
import com.github.pagehelper.Page;

import java.util.List;

/**
 * 
 */
@RestController
@RequestMapping("/ApplyMoney")
public class ApplyMoneyController {
    @Autowired
    private ApplyMoneyService iApplyMoneyService;


    /**
    * 查询全部
    * @param
    * @return
    */
    @GetMapping("/selectAll")
    public R< List<ApplyMoney> > selectAll(){
        return R.ok("查询成功",iApplyMoneyService.selectAll());
    }


    /**
     * 条件查询
     * @param iApplyMoney
     * @return
     */
    @PostMapping("/selectList")
    public R< List<ApplyMoney> > select(@RequestBody ApplyMoney iApplyMoney){
        return R.ok("条件查询成功",iApplyMoneyService.selectList(iApplyMoney));
    }

    /**
     * 新增
     * @param iApplyMoney
     * @return
     */
    @PostMapping("/insert")
    public R insert(@RequestBody ApplyMoney iApplyMoney){
        iApplyMoneyService.insert(iApplyMoney);
        return R.ok("新增成功");
    }


    /**
     * 删除
     * @param ids
     * @return
     */
    @GetMapping("/delete")
    public R delete(@RequestParam String ids){
        iApplyMoneyService.delete(ids);
        return R.ok("删除成功");
    }


    /**
     * 修改
     * @param iApplyMoney
     * @return
     */
    @PostMapping("/update")
    public R update(@RequestBody ApplyMoney iApplyMoney){
        iApplyMoneyService.update(iApplyMoney);
        return R.ok("修改成功");
    }

    /**
    * 分页搜索实现
    * @param page 默认值1
    * @param size 默认值10
    * @return
    */
    @GetMapping(value = "/pageAll" )
    public R pageAll(@RequestParam(defaultValue = "1")  Integer page, @RequestParam(defaultValue = "10") Integer size){
    Page<ApplyMoney> pageList = iApplyMoneyService.pageAll(page, size);
        PageResult pageResult=new PageResult(pageList.getTotal(),pageList.getResult());
        return R.ok("查询成功",pageResult);
    }

    /**
    * 分页条件搜索实现
    * @param iApplyMoney
    * @param page
    * @param size
    * @return
    */
    @GetMapping(value = "/pageList" )
    public R pageList(@RequestBody ApplyMoney iApplyMoney,@RequestParam(defaultValue = "1")  Integer page, @RequestParam(defaultValue = "10") Integer size){
    Page<ApplyMoney> pageList = iApplyMoneyService.pageList(iApplyMoney,page, size);
        PageResult pageResult=new PageResult(pageList.getTotal(),pageList.getResult());
        return R.ok("查询成功",pageResult);
    }
}




